package com.dongdongsongcan.app.control;

import com.dongdongsongcan.app.common.DDMessageDef;
import com.dongdongsongcan.app.common.DDSpKeysDef;
import com.dongdongsongcan.app.control.bean.AddressData;
import com.dongdongsongcan.app.control.bean.AuthnumData;
import com.dongdongsongcan.app.control.bean.DDLocationData;
import com.dongdongsongcan.app.control.bean.DeliverPriceData;
import com.dongdongsongcan.app.control.bean.UserData;
import com.dongdongsongcan.app.control.bean.UserFavorableData;
import com.dongdongsongcan.app.db.UserDao;
import com.dongdongsongcan.app.db.bean.User;
import com.dongdongsongcan.app.model.api.WebServiceApi;
import com.su.dolphin.control.BaseControl;
import com.su.dolphin.control.bean.BaseBean;
import com.su.dolphin.control.task.CtrlTask;
import com.su.dolphin.control.task.CtrlTask.IControlResponse;
import com.su.dolphin.control.task.CtrlTask.IControlWork;
import com.su.dolphin.core.notification.DpMessageCenter;
import com.su.dolphin.utils.DataStoreUtil;
import com.su.dolphin.utils.JSONUtil;
import com.su.dolphin.utils.ui.TipsUtil;

public class AddressControl extends BaseControl {

    private static AddressControl sControl;


    public static AddressControl i() {
        if (sControl == null) {
            sControl = new AddressControl();
        }
        return sControl;
    }


    public void distance_price(final String area_id, final int shop_id, IControlResponse<DeliverPriceData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public DeliverPriceData doWork() {
                DeliverPriceData data = WebServiceApi.distance_price(area_id, shop_id);
                return data;
            }
        }, response);

    }

    public void user_address_list(
            IControlResponse<AddressData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                AddressData authnumData = WebServiceApi
                        .user_address_list();
                return authnumData;
            }
        }, response);

    }

    public void user_address_del(final int info_id, IControlResponse<BaseBean> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                BaseBean authnumData = WebServiceApi.user_address_del(info_id);
                return authnumData;
            }
        }, response);

    }

    public void user_address_insert(final AddressData.Address address, IControlResponse<BaseBean> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                BaseBean data = WebServiceApi.user_address_insert(address);
                return data;
            }
        }, response);

    }

    public void address_nearby(final double latitude, final double longitude, IControlResponse<DDLocationData> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public DDLocationData doWork() {
                DDLocationData data = WebServiceApi.address_nearby(latitude, longitude);
                return data;
            }
        }, response);

    }


	public void user_address_update(final AddressData.Address address, IControlResponse<BaseBean> response) {
        CtrlTask.submitTask(new IControlWork() {

            @Override
            public BaseBean doWork() {
                BaseBean data = WebServiceApi.user_address_update(address);
                return data;
            }
        }, response);

    }

}
